================================================================================
Collect
   flattened device tree (/sys/firmware/fdt)
or
   Expanded Device Tree (/proc/device-tree/)
from target and create
   .dts
   .dtb
   file system tree
on host



================================================================================
"# -- T -----" tags actions to perform on the Target system.

"# -- H -----" tags actions to perform on the Host system.


These instructions assume that the target is accessed with the minicom program
via a serial console.  They can be easily adapted if the target is accessed via
network clients like ssh or telnet.

If network file copy is available, then these instructions can be simplified.

Blocks of commands that are expected to be executed as a block include the ";"
separator and "\" continuation character so the entire block can be pasted
at once.


================================================================================
________________________________________________________________________________
fdt may have been modified by the boot loader or by the kernel early in boot
via struct machine_desc.dt_fixup().


________________________________________________________________________________


# -- T -----  create base64 of fdt /sys/firmware/fdt

fdt=dragon_sys_fdt_`uname -r`
fdt_base64=${fdt}_base64


# -- T -----  copy tar to host, as a base64, via console

echo                                            ; \
echo "  host logfile name: ${fdt_base64}"       ; \
echo                                            ; \
echo "  ON HOST:"                               ; \
echo "     fdt=${fdt}"                          ; \
echo "     fdt_base64=${fdt_base64}"            ; \
echo

# in minicom, ^Azl before <cr> on this command:

base64 /sys/firmware/fdt

# in minicom, ^Azl after base64 command completes, "Close"


# -- H -----  convert base64 to fdt

# set the variables as echoed on target in the previous step


if [ -a ${fdt} ] ; then                                                        \
   echo "ERROR: file or directory ${fdt} already exists" ;                     \
else                                                                           \
   # Used head to strip off last line, because that is the shell prompt ;      \
   # after the base64 command on the target                             ;      \
   base64 -d <(head -n -1 ${fdt_base64})  > ${fdt}.dtb
fi



================================================================================
# Collect /proc/device-tree/ subtree from target and create .dts, .dtb, and/or
# file system tree on host


________________________________________________________________________________


# -- T -----  create tar of device tree as seen in target /proc/device-tree

# /proc/device-tree -> /sys/firmware/devicetree/base

home="/root"
tar_file=dragon_proc-dt_`uname -r`_tar.gz
cd /sys/firmware/devicetree/
tar -zcf ${home}/${tar_file} base/
ls ${home}/${tar_file}


# -- T -----  copy tar to host, as a base64, via console

tar_file_base64=${tar_file}_base64

echo                                            ; \
echo "  host logfile name: ${tar_file_base64}"  ; \
echo                                            ; \
echo "  ON HOST:"                               ; \
echo "     tar_file=${tar_file}"                ; \
echo "     tar_file_base64=${tar_file_base64}"  ; \
echo

# in minicom, ^Azl before <cr> on this command:

base64 ${home}/${tar_file}

# in minicom, ^Azl after base64 command completes, "Close"


# -- H -----  convert base64 to tar, extract tar to base/

# set the variables as echoed on target in the previous step

if [ ! -f ${tar_file_base64} ] ; then
   echo "ERROR: base64 tar file does not exist: ${${tar_file_base64}}"
fi


# Used head to strip off last line, because that is the shell prompt after
# the base64 command on the target
if [ -f ${tar_file} ] ; then
   echo "ERROR: tar file already exists: ${tar_file}"
else
   base64 -d <(head -n -1 ${tar_file_base64})  > ${tar_file}
fi


if [ -a base ] ; then                                                          \
   echo "ERROR: file or directory 'base' already exists" ;                     \
else                                                                           \
   tar -xf ${tar_file} --exclude=testcase-data ;                               \
fi


================================================================================
